package com.slz.crm.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slz.crm.pojo.ao.Privacy;
import com.slz.crm.pojo.entity.BusinessActivityEntity;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 商业活动视图对象
 */
@Data
public class BusinessActivityVO implements Privacy {
    /**
     * 商业活动ID
     */
    private Long id;
    /**
     * 商业活动标题
     */
    private String activityTitle;
    /**
     * 商业活动内容
     */
    private String activityContent;
    /**
     * 公司ID
     */
    private Long companyId;
    /**
     * 公司名称
     */
    private String companyName;
    /**
     * 活动时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime activityTime;
    /**
     * 类型
     */
    private String activityType;
    /**
     * 时长
     */
    private Integer activityDuration;
    /**
     * 机会ID
     */
    private Long opportunityId;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    /**
     * 备注
     */
    private String remark;
    /**
     * 创建者ID
     */
    private Long creatorId;
    /**
     * 创建者名字
     */
    private String creatorName;
    /**
     * 销售机会名称
     */
    private String opportunityName;

    /**
     * 从Entity创建VO，需要传入公司名称、创建者名称和销售机会名称
     * @param entity 商业活动实体
     * @param companyName 公司名称
     * @param creatorName 创建者姓名
     * @param opportunityName 销售机会名称
     * @return BusinessActivityVO
     */
    public static BusinessActivityVO fromEntity(BusinessActivityEntity entity, String companyName, String creatorName, String opportunityName) {
        if (entity == null) {
            return null;
        }

        BusinessActivityVO vo = new BusinessActivityVO();
        vo.setId(entity.getId());
        vo.setActivityTitle(entity.getActivityTitle());
        vo.setActivityContent(entity.getActivityContent());
        vo.setCompanyId(entity.getCompanyId());
        vo.setCompanyName(companyName);
        vo.setActivityTime(entity.getActivityTime());
        vo.setActivityType(entity.getActivityType());
        vo.setActivityDuration(entity.getActivityDuration());
        vo.setOpportunityId(entity.getOpportunityId());
        vo.setCreateTime(entity.getCreateTime());
        vo.setRemark(entity.getRemark());
        vo.setCreatorId(entity.getCreatorId());
        vo.setCreatorName(creatorName);
        vo.setOpportunityName(opportunityName);

        return vo;
    }


}
